﻿using ScanConfirm.Handle;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace ScanConfirmForm
{
    public partial class FrmLogin : Form
    {
        ScanConfirmHandler scanConfirmHandler;

        public FrmLogin()
        {
            InitializeComponent();
            scanConfirmHandler = ScanConfirmHandler.getInstance();
            if (scanConfirmHandler.User != null)
                txtUser.Text = scanConfirmHandler.User.LoginName;
        }

        private void btnCancel_Click(object sender, EventArgs e)
        {
            this.DialogResult = DialogResult.Cancel;
            this.Close();
        }

        private void btnLogin_Click(object sender, EventArgs e)
        {
            var result = scanConfirmHandler.Login(txtUser.Text.Trim(),txtPassword.Text.Trim());
            if(result)
            {
                this.DialogResult = DialogResult.OK;
                this.Close();
            }
            else
            {
                MessageBox.Show("用户名或密码错误！");
            }
        }
    }
}
